<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<link rel="stylesheet" href="./css/setting.css">
		<!--<link rel="stylesheet" href="./css/common.css">-->
		<link rel="stylesheet" type="text/css" href="./css/hui.css" />
		<title>密码更改</title>
	</head>
	<style>
		.title {
            width: 100px;
            height: 40px;
            line-height: 40px;
            position: absolute;
            left: 50%;
            margin-left: -50px;
            font-size: 17px;
            color: #030303;
        }

        #hui-back:before {
            color: #2439A5;
        }
        .hui-header {
            background: rgba(248, 248, 248, 0.82);
        }

        .hui-header h1 {
            font-size: 17px;
        }

</style>
	<body>
		<!--<header>-->
		<!--<img id="hui-back" src="./img/back.png" alt="back">密码更改-->
		<!--</header>-->
		<header class="hui-header">
			<div id="hui-back"></div>
			<span class="title">密码更改</span>
		</header>
		<div class="hui-wrap">
			<form id="from">
				<main class="modify form">
					<div class="line">
						<div class="name">原始密码</div>
						<input id="n" placeholder="请输入原始密码" type="password">
					</div>
					<div class="line">
						<div class="name">新密码</div>
						<input id="n1" placeholder="请设置6-20位新的登录密码" type="password" checkType="string" checkData="6,20" checkMsg="密码应为6-20个字符">
					</div>
					<div class="line">
						<div class="name">确认密码</div>
						<input id="n2" placeholder="请再次输入新的登录密码" type="password">
					</div>
				</main>
			</form>
		</div>

		<button onclick="sb()" type="submit">提交</button>
		<script src="./js/jquery.min.js"></script>
		<script src="js/fastclick.js"></script>
		<script>
			$(function() {
				FastClick.attach(document.body);
			});
		</script>
		<script src="./js/chen-url.js"></script>
		<script src="./js/hui.js" type="text/javascript" charset="utf-8"></script>
		<script>
			function sb() {
				if ($("#n1").val() == "") {
					hui.iconToast("请输入密码！", 'warn');
				}
				<!--hui.iconToast(formData, 'warn');-->
				if ($("#n1").val() != $("#n2").val()) {
					hui.iconToast("新密码不一致！", 'warn');
					return false;
				}
				var formData = new FormData();
				formData.append("newpwd", $("#n1").val());
				formData.append("oldpwd", $("#n").val());
				formData.append("id", localStorage.getItem("id"));
				$.ajax({
					url: address + 'user/updatePwd',
					type: 'post',
					dataType: 'json',
					processData: false,
					contentType: false,
					data: formData,
					success: function(data) {
						if (data.code == 200) {
							hui.iconToast("修改成功", 'success');
							localStorage.removeItem("num");
							localStorage.removeItem("photo");
							localStorage.removeItem("id");
							localStorage.removeItem("name");
							localStorage.removeItem("uasername");
							localStorage.removeItem("password");
							localStorage.removeItem("need");
							localStorage.removeItem("rphone");

							nativeMethod.backLogin();
						} else {
							hui.iconToast(data.data, 'success');
						}

					},
					error: function(data) {
						hui.iconToast("修改失败，请重试！", 'warn');
					}
				})
			}
		</script>
		<script>
			function aa(path) {}
		</script>
	</body>
</html>
